package com.atguigu.srb.mybatisPlus;

import com.atguigu.srb.mybatisPlus.mapper.UserMapper;
import com.atguigu.srb.mybatisPlus.pojo.entity.User;
import com.atguigu.srb.mybatisPlus.service.UserService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import javax.annotation.Resource;

@SpringBootTest
public class PageSelect {

    @Autowired
    UserService userService;

    @Resource
    UserMapper userMapper;

    /**
     * 分页查询
     */
    @Test
    public void pageSelect(){
        Page<User> userPage = new Page<>();
        userPage.setSize(1);
        userPage.setCurrent(2);
        userService.page(userPage);
    }

    /**
     * 自定义分页查询
     */
    @Test
    public void pageSelect2(){
        Page<User> userPage = new Page<>();
        userPage.setSize(1);
        userPage.setCurrent(2);
        userMapper.selectAllByNamePage("j",userPage);
    }
}
